<?php

/*
  Transaction FT - FileTransfer Module Version 2.0

 */
MYTCONN();
require_once("tft_comuns.php");
$TransmissionResultCode = 1;
/* SQL CONFIG DISABLED
 * $GetSettings = $GLOBALS['MYT']->db_array("SELECT set_Valor FROM hd_globalsettings WHERE set_ID = 46");
 */
$GetSettings[1]['set_Valor'] = $__sysTFTImport_Directory;

#  $dir = $GLOBALS['DOC'].'TRANSMIS/TRANSACT/OUTGOING/';
$DatadirTransmitionOut = $GLOBALS['DOC'] . 'TRANSACT/OUTGOING/';
$DatadirTransmitionInc = $GLOBALS['DOC'] . 'TRANSACT/INCOME/';

$TFTPATH_MODELS = $GLOBALS['LIB'] . 'FileTemplates/TransactModels/';

if (!isset($procedure) || $procedure == '') {
    die('undefined procedure');
}
if ($GETCOMMETH[1]['tcmtLink'] == '') {
    $error = 'undefined model.';
} else {
    $GetMethodParams = $GLOBALS['MYT']->db_array("SELECT * FROM hd_fileformats WHERE REF = " . $GETCOMMETH[1]['tcmtLink']);
}
if (isset($GetMethodParams[1])) {

    if (!isset($GetSettings[1])) {
        die("Invalid Request");
    }
    $PrefixIndex[161] = array('TR', 'Tr');
    $PrefixIndex[165] = array('SR', 'In');
    $PrefixIndex[167] = array('SR', 'In');
    $PrefixIndex[170] = array('SR', 'In');
    $PrefixIndex[177] = array('PL', 'Ac');

    $CORRESP_FTDIR = $GETCOMMETH[1]['CorrAgente'];
    if ($GETCOMMETH[1]['tcmtCorrPNAME'] == 'Get') {
        $TrsResultCode = doCommunication($GETCOMMETH, $PID, $GetSettings[1]['set_Valor']);
    }
    unset($error);
    unset($handle);
    unset($FileList);
    unset($pl);

    include("tft_" . $procedure . ".php");

    if ($GETCOMMETH[1]['tcmtCorrPNAME'] == 'Put') {
        $TrsResultCode = doCommunication($GETCOMMETH, $PID, $GetSettings[1]['set_Valor']);
    }
} else {
    echo $error = 'Missing Model.' . $PID;
}